<?php
/* @var $this AssignmentController */
/* @var $model User */
/* @var $authItemDp AuthItemDataProvider */
/* @var $formModel AddAuthItemForm */
/* @var $form TbActiveForm */
/* @var $assignmentOptions array */

$this->breadcrumbs = array(
    Yii::t('AuthModule.main', 'Assignments') => array('index'),
    CHtml::value($model, $this->module->userNameColumn),
);
?>
<div class="row">
	<div class="col-lg-12">
		<div class="panel panel-danger">
			<div class="panel-heading">
				<h4>用户授权</h4>
				<div class="options">
				<?php $this->widget(
        'bootstrap.widgets.BsNav',
        array(
            'type' => BSHtml::NAV_TYPE_TABS,
            'items' => array(
                array(
                    'label' => Yii::t('AuthModule.main', 'Assignments'),
                    'url' => array('/auth/assignment/index'),
                    'active' => $this instanceof AssignmentController,
                ),
                array(
                    'label' => $this->capitalize($this->getItemTypeText(CAuthItem::TYPE_ROLE, true)),
                    'url' => array('/auth/role/index'),
                    'active' => $this instanceof RoleController,
                ),
                array(
                    'label' => $this->capitalize($this->getItemTypeText(CAuthItem::TYPE_TASK, true)),
                    'url' => array('/auth/task/index'),
                    'active' => $this instanceof TaskController,
                ),
                array(
                    'label' => $this->capitalize($this->getItemTypeText(CAuthItem::TYPE_OPERATION, true)),
                    'url' => array('/auth/operation/index'),
                    'active' => $this instanceof OperationController,
                ),
            ),
        )
    );?>
    </div>
			</div>
			<div class="panel-body">
        <?php $this->widget(
            'bootstrap.widgets.BsGridView',
            array(
                'type' => 'striped condensed hover',
                'dataProvider' => $authItemDp,
                'emptyText' => Yii::t('AuthModule.main', 'This user does not have any assignments.'),
                'hideHeader' => true,
                'template' => "{items}",
                'columns' => array(
                    array(
                        'class' => 'AuthItemDescriptionColumn',
                        'active' => true,
                    ),
                    array(
                        'class' => 'AuthItemTypeColumn',
                        'active' => true,
                    ),
                    array(
                        'class' => 'AuthAssignmentRevokeColumn',
                        'userId' => $model->{$this->module->userIdColumn},
                    ),
                ),
            )
        ); ?>

        <?php if (!empty($assignmentOptions)): ?>

            <h4><?php echo Yii::t('AuthModule.main', 'Assign permission'); ?></h4>

            <?php $form = $this->beginWidget(
                'bootstrap.widgets.BsActiveForm',
                array(
                    'layout' => BsHtml::FORM_LAYOUT_INLINE,
                )
            ); ?>

            <?php echo $form->dropDownList($formModel, 'items', $assignmentOptions, array('label' => false)); ?>

            <?php echo BSHtml::submitButton(
                Yii::t('AuthModule.main', 'Assign'),
                array(
                    'color' => BSHtml::BUTTON_COLOR_PRIMARY,
                )
            ); ?>

            <?php $this->endWidget(); ?>

        <?php endif; ?>

    </div> <!-- end panel-body -->
		</div>
	</div>
</div> <!-- end row -->